/*
 * PACKAGE NAME: com.jodinfo.outmirror.api.loseformbarcode.controller
 * FILE    NAME: LoseformBarcodeDaoImpl.java
 * COPYRIGHT: Copyright(c) © 2016 heroj Company Ltd. All Rights Reserved
 */ 
package com.jodinfo.outmirror.api.loseformbarcode.controller;

import java.math.BigInteger;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.hero.common.web.context.UserContext;
import com.hero.core.constant.SysConstant;
import com.hero.core.entity.ResponseEntity;
import com.jodinfo.outmirror.api.loseformbarcode.entity.LoseformBarcodeEntity;
import com.jodinfo.outmirror.api.loseformbarcode.service.LoseformBarcodeBizService;



@Controller
@RequestMapping(value = "/LoseformBarcodeAdmin")
public class LoseformBarcodeController  {
	
@Resource(name="loseformBarcodeBizService")
private LoseformBarcodeBizService LoseformBarcodeBizService;
/**
*  list数据源
* 
* */
@RequestMapping(value = "/List")
@ResponseBody
public String LoseformBarcodeList(LoseformBarcodeEntity LoseformBarcodeEntity) {
	if(LoseformBarcodeEntity==null){
		LoseformBarcodeEntity = new LoseformBarcodeEntity();
		LoseformBarcodeEntity.setPageIndex(SysConstant.DEFAULT_PAGEINDEX); 
		LoseformBarcodeEntity.setPageSize(SysConstant.DEFAULT_PAGESIZE);
	}
	LoseformBarcodeEntity.setCurrentUser(UserContext.getUser());
	LoseformBarcodeEntity.setIsDel(SysConstant.IS_DEL_N); 
	String str = LoseformBarcodeBizService.queryListForPageLoseformBarcode(LoseformBarcodeEntity);
	return str;
}
@RequestMapping(value = "/ListAll")
@ResponseBody
public String LoseformBarcodeListAll(LoseformBarcodeEntity LoseformBarcodeEntity) {
	String str = LoseformBarcodeBizService.queryAllLoseformBarcode(LoseformBarcodeEntity);
	return str;
}
/**
* LoseformBarcodeEntity List页面
* 
* */
@RequestMapping(value = "/ListPage")
public ModelAndView LoseformBarcodeListPage(LoseformBarcodeEntity LoseformBarcodeEntity,HttpServletRequest request) {
	
	return new ModelAndView(returnPath("LoseformBarcodeList"));
}
/**
* LoseformBarcodeEntity详细页 
* 
* */
@RequestMapping(value = "/EditPage")
public ModelAndView LoseformBarcodeEditPage(LoseformBarcodeEntity LoseformBarcodeEntity) {
	
	return new ModelAndView(returnPath("LoseformBarcodeAdd"));
}
/**
 * 查询LoseformBarcodeEntity
 * 
 * */
@RequestMapping(value = "/queryByID")
public @ResponseBody String findLoseformBarcodeData(HttpServletRequest request) {
	String id = request.getParameter("id");
	LoseformBarcodeEntity LoseformBarcodeEntity =  LoseformBarcodeBizService.queryById(new BigInteger(id));
	return JSON.toJSONString(LoseformBarcodeEntity); 
}

/**
 * 保存或更新LoseformBarcode 
 * 
 * */
@RequestMapping(value = "/saveLoseformBarcode")
public @ResponseBody String saveLoseformBarcodeData(@RequestBody LoseformBarcodeEntity LoseformBarcodeEntity) {
	ResponseEntity rs = null;
	if(LoseformBarcodeEntity!=null){
		LoseformBarcodeEntity.setCurrentUser(UserContext.getUser());
		if(LoseformBarcodeEntity.getId()!=null){
			rs = LoseformBarcodeBizService.updateLoseformBarcode(LoseformBarcodeEntity);
		}else{
			rs = LoseformBarcodeBizService.addLoseformBarcode(LoseformBarcodeEntity);
		}
	}
	return JSON.toJSONString(rs);
}
/**
 * 导出LoseformBarcodeEntity
 * @author weiwei
 * @date 2015-7-09  下午2:13:28
 * @return
 */
@RequestMapping(value = "/exportLoseformBarcodeExcel")
public void exportLoseformBarcodeExcel(LoseformBarcodeEntity LoseformBarcodeEntity,HttpServletResponse response) {
	LoseformBarcodeEntity.setCurrentUser(UserContext.getUser());
	LoseformBarcodeEntity.setIsDel(SysConstant.IS_DEL_N);
	LoseformBarcodeBizService.exportLoseformBarcode(LoseformBarcodeEntity, response);
}


 /**
 * 
 * 批量删除
 * @author weiwei
 * @date 2017年3月13日 下午2:48:57
 * @param LoseformBarcodeEntity
 * @return
 */
@RequestMapping(value = "/batchDelLoseformBarcode")
public @ResponseBody String batchDelLoseformBarcode(LoseformBarcodeEntity LoseformBarcodeEntity) {
	ResponseEntity rs = null;
	rs = LoseformBarcodeBizService.batchDelLoseformBarcode(LoseformBarcodeEntity);
	return  JSON.toJSONString(rs);
}
/**
 * 定义
 * 
 */
private final String MODULE_PATH = "/loseformbarcode/";

//返回路径
private String returnPath(String jspName) {
	return MODULE_PATH + jspName;
}
}
